using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using DAL;
using Utility;

public partial class PH_DN_loaisanphamsua : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            LoadData();
        }
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbloaispDTO sp = tbloaisanphamBUS.GetByID(id);
            if (sp != null)
            {

                //txt_MaSp.Text = sp.Masp.ToString();
                txt_tenloai.Text = sp.Tenloaisp;



            }
        }
        catch
        {
            Response.Redirect("loaisanphamlist.aspx");
        }
    }
    protected void btn_Update_Click(object sender, EventArgs e)
    {
        try
        {
            tbloaispDTO loai = new tbloaispDTO();
            //sanpham.Masp = int.Parse(txt_MaSp.Text);
            loai.Tenloaisp = txt_tenloai.Text;



            tbloaisanphamBUS.Update(loai);
            Response.Redirect("loaisanphamlist.aspx");
            Label_thanhcong.Text = tbnhanvienBUS.error;
        }

        catch
        {
            Label_thanhcong.Text = tbsanphamBUS.error;
            Response.Redirect("loaisanphamlist.aspx");
        }
    }
}
